package com.xzk.user.controller;

import com.xzk.user.pojo.User;
import com.xzk.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Classname UserController
 * @Description TODO
 * @Date 2020/9/22 11:04
 * @Created by ccc-j
 * @email ccc-ju@outlook.com
 */
@RestController
@RequestMapping("/user")
@RefreshScope //配置文件改变自动刷新属性
public class UserController {

    @Autowired
    private UserService userService;

    @Value("${test.name}")
    private String name;

    @GetMapping("/{id}")
    public User queryById(@PathVariable Long id){
        /*try{
            Thread.sleep(2000);
        }catch (InterruptedException e){
            log.error("休眠出错了！");
            e.printStackTrace();
        }*/
        System.out.println("配置中心的test.name:" + name);
        return userService.queryById(id);
    }

}
